<template>
	<view class="video-box">
		<videoPlayVue :video-list="state.videoList" @loadMore="loadMore" :loadMoreOffsetCount="loadMoreOffsetCount">
			<!-- 此处data是从子组件获取的数据 不明白参考https://cn.vuejs.org/guide/components/slots.html#dynamic-slot-names-->
			<template v-slot="data">
				<view class="right-box">
					<view class="user-head-src-box">
						<image class="video-user-head-src" :src="data.item.headSrc" />
						<view v-if="!data.item.concernStatus" class="follow-with-interest">
							<up-icon size="14px" color="#fff" name="plus" />
						</view>
						<view v-else class="follow-with-interest active-follow-with-interest">
							<up-icon size="20px" color="#fff" name="checkmark" />
						</view>
					</view>
					<view class="info-box">
						<view class="item-box">
							<up-icon size="36px" color="#fff" name="heart-fill" />
							<text>{{ data.item.totalLikes }}</text>
						</view>

						<view class="item-box">
							<up-icon size="36px" color="#fff" name="chat" @click="handleComment" />
							<text>{{ data.item.totalComments }}</text>
						</view>

						<view class="item-box">
							<up-icon size="36px" :color="data.item.collectsStatus ? '#fd6200' : '#fff'"
								name="star-fill" />
							<text>{{ data.item.tatalCollects }}</text>
						</view>

						<view class="item-box">
							<up-icon size="36px" color="#fff" name="share-square" />
							<text>{{ data.item.totalForwards }}</text>
						</view>
					</view>
				</view>

				<view class="bottom-info-box">
					<view class="bottom-user-name">{{ data.item.userName }}</view>
					<view class="bottom-user-content">{{ data.item.content }}</view>
				</view>
			</template>
		</videoPlayVue>
		<!-- 评论弹窗 -->
		<PopupVue :popupShow="popupShow" @closeCB="popupShow = false" />
	</view>
</template>

<script setup lang="ts">
	import PopupVue from '../popupComponents/index.vue';
	import videoPlayVue from './video-play.vue';
	import { defineProps, ref, reactive, watch } from 'vue';

	// 引入组件
	components: {
		videoPlayVue;
		PopupVue
	};

	const props = defineProps({
		tabsId: String || null
	});

	// 弹窗状态
	const popupShow = ref(false)

	const videoRefs = ref([]);
	// 当前播放的视频索引 
	const currentPlayingVideo = ref(null)

	// 短视频数据格式
	const state = reactive({
		videoList: [
			{
				id: 1,
				concernStatus: false, // 关注状态
				collectsStatus: true, // 收藏状态
				headSrc: 'https://www.cosplayla.com/picup/cospic/202402/10495_1708783433236_200.jpg', // 头像
				videoSrc: 'https://img.chenggua.com/mnzcdcjgs.mp4', // 视频地址
				userName: '@花木兰', // 作者名称
				content: '#木兰从军，代父征战', // 内容
				totalLikes: 109, // 总点赞数
				totalComments: 75, // 总评论数
				tatalCollects: 130, // 总收藏数
				totalForwards: 4, // 总转发数
			},
			{
				id: 4,
				concernStatus: false, // 关注状态
				collectsStatus: true, // 收藏状态
				headSrc: 'https://www.cosplayla.com/picup/cospic/202402/10495_1708783433236_200.jpg', // 头像
				videoSrc: 'http://vjs.zencdn.net/v/oceans.mp4', // 视频地址
				userName: '@花木兰', // 作者名称
				content: '#木兰从军，代父征战', // 内容
				totalLikes: 109, // 总点赞数
				totalComments: 75, // 总评论数
				tatalCollects: 130, // 总收藏数
				totalForwards: 4, // 总转发数
			},
			{
				id: 5,
				concernStatus: false, // 关注状态
				collectsStatus: true, // 收藏状态
				headSrc: 'https://www.cosplayla.com/picup/cospic/202402/10495_1708783433236_200.jpg', // 头像
				videoSrc: 'https://xjc.demo.hongcd.com/uploads/20210128/0c64cbeea28b10c06eee8728c762449e.mp4', // 视频地址
				userName: '@花木兰', // 作者名称
				content: '#木兰从军，代父征战', // 内容
				totalLikes: 109, // 总点赞数
				totalComments: 75, // 总评论数
				tatalCollects: 130, // 总收藏数
				totalForwards: 4, // 总转发数
			},
			{
				id: 6,
				concernStatus: false, // 关注状态
				collectsStatus: true, // 收藏状态
				headSrc: 'https://www.cosplayla.com/picup/cospic/202402/10495_1708783433236_200.jpg', // 头像
				videoSrc: 'https://xjc.demo.hongcd.com/uploads/20210327/1b72e1b6153cd29df07f5449991e8083.mp4', // 视频地址
				userName: '@花木兰', // 作者名称
				content: '#木兰从军，代父征战', // 内容
				totalLikes: 109, // 总点赞数
				totalComments: 75, // 总评论数
				tatalCollects: 130, // 总收藏数
				totalForwards: 4, // 总转发数
			},
			{
				id: 7,
				concernStatus: false, // 关注状态
				collectsStatus: true, // 收藏状态
				headSrc: 'https://www.cosplayla.com/picup/cospic/202402/10495_1708783433236_200.jpg', // 头像
				videoSrc: 'https://xjc.demo.hongcd.com/uploads/20230214/7e1a0baaebc4e656bbbfbc44d7a55a60.mp4', // 视频地址
				userName: '@花木兰', // 作者名称
				content: '#木兰从军，代父征战', // 内容
				totalLikes: 109, // 总点赞数
				totalComments: 75, // 总评论数
				tatalCollects: 130, // 总收藏数
				totalForwards: 4, // 总转发数
			},
		],
	});
	
	const loadMoreOffsetCount = ref(state.videoList.length)

	// 点击评论
	const handleComment = () => {
		popupShow.value = true
	}
	
	// 下滑事件
	const loadMore = () => {
		console.log('下滑事件=====')
	}
</script>

<style lang="scss" scoped>
	.video-box {
		width: 100%;
		height: calc(100vh - 100rpx);
		// margin-top: 100rpx;
		background-color: #fff;

		.right-box {
			position: absolute;
			bottom: 120rpx;
			right: 24rpx;
			width: 120rpx;
			z-index: 99999;
			display: flex;
			flex-direction: column;
			align-items: center;

			.user-head-src-box {
				position: relative;

				.video-user-head-src {
					display: block;
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
				}

				.follow-with-interest {
					width: 48rpx;
					height: 48rpx;
					border-radius: 50%;
					background-color: red;
					color: #fff;
					font-size: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					position: absolute;
					bottom: -20rpx;
					left: 50%;
					margin-left: -24rpx;
				}

				.active-follow-with-interest {
					background-color: #fd6200;
				}
			}

			.info-box {
				margin-top: 100rpx;

				.item-box {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 42rpx;

					text {
						font-size: 28rpx;
						color: #fff;
					}
				}
			}
		}

		.bottom-info-box {
			position: absolute;
			bottom: 80rpx;
			left: 24rpx;
			width: calc(100% - 140rpx);
			z-index: 99999;

			.bottom-user-name {
				font-size: 32rpx;
				color: #fff;
			}

			.bottom-user-content {
				margin: 24rpx 0;
				font-size: 28rpx;
				color: #fff;
			}
		}
	}
</style>